//
//  AppShareViewXib.m
//  com.yjwh.yj
//
//  Created by ferver7 on 2018/10/30.
//  Copyright © 2018年 ferver7. All rights reserved.
//

#import "AppShareViewXib.h"


@implementation AppShareViewXib

- (IBAction)cancerAction:(id)sender {
    [GKCover hide];
}
- (IBAction)wxLogin:(id)sender { //微信好友
    [GKCover hide];
    [self shareWithType:0];
}
- (IBAction)phoneLogin:(id)sender {//微信朋友圈
    [GKCover hide];
    [self shareWithType:1];
}
-(void)shareWithType:(int)shareType
{
    [WXApiManager sharedManager].delegate = self;
   
    WXMediaMessage * mesage = [WXMediaMessage message];
//    mesage.title = [AppUserBaseModel sharedUserData].storeName;
//    mesage.description = [AppUserBaseModel sharedUserData].detailedAddress;
    mesage.title = @"来自摩嗒嗒的分享";
    mesage.description = @"摩嗒嗒，一站式服务！";

//    NSData * imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:[AppUserBaseModel sharedUserData].doorImage]];
//    UIImage * acImage = [UIImage imageWithData:imageData];  //店铺的图片

    
    [mesage setThumbImage:[UIImage imageNamed:@"iconLog"]];
    WXWebpageObject * webPageObject = [WXWebpageObject object];
    
    if (self.typeInt == 1) {//店铺
        webPageObject.webpageUrl = [NSString stringWithFormat:@"https://www.hnmobang.com/aschouas-oak/app/person/myStore/%@",[AppUserBaseModel sharedUserData].uid];
    }else if (self.typeInt ==2){//加盟
        webPageObject.webpageUrl = [NSString stringWithFormat:@"https://www.hnmobang.com/aschouas-oak/app/join/1"];

    }else if (self.typeInt ==3){//头条
        webPageObject.webpageUrl = [NSString stringWithFormat:@"https://www.hnmobang.com/aschouas-oak/app/headLine/%@",self.activityInfo[@"oid"]];
    }

    mesage.mediaObject = webPageObject;
    
    SendMessageToWXReq * req = [[SendMessageToWXReq alloc]init];
    req.bText = NO;
    req.message = mesage;
    req.scene = shareType;
    [WXApi sendReq:req];
    
    
}
- (void)managerDidRecvMessageResponse:(SendMessageToWXResp *)response
{
    if ([AppUserBaseModel sharedUserData]) {
//        int errCode = response.errCode; //0关闭
        switch (response.errCode)
        {
            case WXSuccess://学馆分享类型 6
            {
                
            }
            case WXErrCodeUserCancel:
            {
                [AxcUI_Toast AxcUI_showCenterWithText:@"用户取消分享"];
                break;
            }
            default:
            {
                [AxcUI_Toast AxcUI_showCenterWithText:@"分享失败"];
                break;
            }
        }
    }
}
-(void)awakeFromNib
{
    [super awakeFromNib];
    self.wxLogin.axcUI_buttonContentLayoutType = AxcButtonContentLayoutStyleCenterImageTop;
    self.wxLogin.axcUI_padding = 20;
    self.phoneLogin.axcUI_buttonContentLayoutType = AxcButtonContentLayoutStyleCenterImageTop;
    self.phoneLogin.axcUI_padding = 20;
}

@end
